<template>
	<view>
		<view @tap="close" :class="maskClass" class="bottom-layer animate__animated animate__faster "></view>
		
		<view :class="layerClass" class="bottom-layer-content animate__animated animate__faster animate__slideInUp">
			<view class="title">
				<text class="label">{{title}}</text>
				<text @tap="close" class="iconfont icon-guanbi1"></text>
			</view>
			
			<slot/>
			
			<view class="foot-btn">
				<view class="cancel" @tap="close">取消</view>
				<view class="confirm" @tap="$emit('confirm')">确定</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"bottom-layer",
		props:{
			title:{
				type:String,
				default:'标题'
			}
		},
		data() {
			return {
				visible:false,
				maskClass:'',
				layerClass:'',
			};
		},
		watch:{
			visible(val){
				if(val){
					this.maskClass = 'show animate__fadeIn'
					this.layerClass = 'show animate__slideInUp'
				}
				else{
					this.maskClass = 'show animate__fadeOut'
					this.layerClass = 'show animate__slideOutDown'
					setTimeout(()=>{
						this.maskClass = ''
						this.layerClass = ''
					},500)
				}
			}
		},
		methods:{
			
			// 关闭弹窗
			close(){
				this.$emit('calcel')
				this.visible = false
			},
			
			// 打开弹窗
			open(){
				this.visible = true
			},
		}
	}
</script>

<style lang="scss" scoped>
.bottom-layer-content{
	position: fixed;
	background: #fff;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 9;
	display: none;
	&.show{
		display: block;
	}
	
	.title{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx;
		.label{
			font-size: 34rpx;
			color: #6C7D8C;
		}
		.iconfont{
			font-size: 36rpx;
			color: #999;
		}
	}
	.foot-btn{
		display: flex;
		justify-content: flex-end;
		padding: 30rpx;
		.cancel{
			background: #f5f5f5;
			padding: 10rpx 30rpx;
			margin-right: 20rpx;
			font-size: 28rpx;
			color: #555;
			border-radius: 4rpx;
		}
		.confirm{
			background: #8bcf70;
			padding: 10rpx 30rpx;
			margin-right: 20rpx;
			font-size: 28rpx;
			color: #fff;
			border-radius: 4rpx;
		}
	}
}	
	
.bottom-layer{
	background: rgba(0,0,0,0.3);
	position: fixed;
	z-index: 8;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: none;
	&.show{
		display: block;
	}
}
</style>
